package com.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.user.domain.Menber;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;

/**
 * @author YU
 * @description 针对表【menber】的数据库操作Mapper
 * @createDate 2024-04-15 11:36:11
 * @Entity .com.user.com.user.domain.Menber
 */
public interface MenberMapper extends BaseMapper<Menber> {

    /**
     * 判断当前餐厅的会员等级是否已经存在
     *
     * @param restaurantId 餐厅id
     * @param member       会员等级
     * @return boolean
     */
    @Select("select count(1) from menber where restaurant_id = #{restaurantId} and member = #{member}")
    boolean isMenberExist(Integer restaurantId, String member);

    @Select("select count(1) from menber where restaurant_id = #{restaurantId} and member = #{member} and id != #{id}")
    boolean isMenberExistNo(Integer restaurantId, String member, Integer id);

    @Select("select discount from menber where id = #{memberId}")
    BigDecimal selectMenberDiscountById(Integer memberId);

    @Select("select member from menber where id = #{menberId}")
    String selectMenberById(Integer menberId);
}




